package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysOrderEvaluationMapper;
import com.ruoyi.system.domain.SysOrderEvaluation;
import com.ruoyi.system.service.ISysOrderEvaluationService;

/**
 * 订单评价Service业务层处理
 *
 * @author ruoyi
 * @date 2024-07-27
 */
@Service
public class SysOrderEvaluationServiceImpl implements ISysOrderEvaluationService
{
    @Autowired
    private SysOrderEvaluationMapper sysOrderEvaluationMapper;
    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询订单评价
     *
     * @param evaId 订单评价主键
     * @return 订单评价
     */
    @Override
    public SysOrderEvaluation selectSysOrderEvaluationByEvaId(Long evaId)
    {
        return sysOrderEvaluationMapper.selectSysOrderEvaluationByEvaId(evaId);
    }

    /**
     * 查询订单评价列表
     *
     * @param sysOrderEvaluation 订单评价
     * @return 订单评价
     */
    @Override
    public List<SysOrderEvaluation> selectSysOrderEvaluationList(SysOrderEvaluation sysOrderEvaluation)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = sysUserMapper.selectUserById(loginUser.getUserId());
        sysOrderEvaluation.setSupplierId(user.getSupplierId());
        return sysOrderEvaluationMapper.selectSysOrderEvaluationList(sysOrderEvaluation);
    }

    /**
     * 新增订单评价
     *
     * @param sysOrderEvaluation 订单评价
     * @return 结果
     */
    @Override
    public int insertSysOrderEvaluation(SysOrderEvaluation sysOrderEvaluation)
    {
        return sysOrderEvaluationMapper.insertSysOrderEvaluation(sysOrderEvaluation);
    }

    /**
     * 修改订单评价
     *
     * @param sysOrderEvaluation 订单评价
     * @return 结果
     */
    @Override
    public int updateSysOrderEvaluation(SysOrderEvaluation sysOrderEvaluation)
    {
        return sysOrderEvaluationMapper.updateSysOrderEvaluation(sysOrderEvaluation);
    }

    /**
     * 批量删除订单评价
     *
     * @param evaIds 需要删除的订单评价主键
     * @return 结果
     */
    @Override
    public int deleteSysOrderEvaluationByEvaIds(Long[] evaIds)
    {
        return sysOrderEvaluationMapper.deleteSysOrderEvaluationByEvaIds(evaIds);
    }

    /**
     * 删除订单评价信息
     *
     * @param evaId 订单评价主键
     * @return 结果
     */
    @Override
    public int deleteSysOrderEvaluationByEvaId(Long evaId)
    {
        return sysOrderEvaluationMapper.deleteSysOrderEvaluationByEvaId(evaId);
    }
}
